home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Inne / Gry / Carnage_Contest / scripts / CC Original / tools / Pick.lua < prev    next >
Text File  |  2009-09-13  |  3KB  |  77 lines

  1. --------------------------------------------------------------------------------
  2. -- Weapon Pick
  3. -- Original Carnage Contest Weapon
  4. -- Script by DC, August 2009, www.UnrealSoftware.de
  5. --------------------------------------------------------------------------------
  6.  
  7. -- Setup Tables
  8. if cc==nil then cc={} end
  9. cc.pick={}
  10.  
  11. -- Load & Prepare Ressources
  12. cc.pick.gfx_wpn=loadgfx("weapons/pick.bmp")                            -- Weapon Image
  13. setmidhandle(cc.pick.gfx_wpn)
  14. cc.pick.sfx_attack=loadsfx("swish.ogg")                                -- Attack Sound
  15. cc.pick.sfx_hitground=loadsfx("crumble.ogg")                        -- Hit Ground Sound
  16.  
  17. --------------------------------------------------------------------------------
  18. -- Weapon: Pick
  19. --------------------------------------------------------------------------------
  20.  
  21. cc.pick.id=addweapon("cc.pick","Pick",cc.pick.gfx_wpn)                -- Add Weapon
  22. cc.pick.ammo=3                                                        -- 3 Digs
  23.  
  24. function cc.pick.draw()                                                -- Draw
  25.     -- Draw
  26.     if getplayeraction(0)==0 then
  27.         setblend(blend_alpha)
  28.         setalpha(1)
  29.         setcolor(255,255,255)
  30.         setscale(-getplayerdirection(0),1)
  31.         setrotation(getplayerrotation(0)-(30-(weapon_timer*3))*(getplayerdirection(0)))
  32.         drawimage(cc.pick.gfx_wpn,getplayerx(0)+getplayerdirection(0)*7,getplayery(0)+3)
  33.     end
  34.     -- HUD ammobar
  35.     if cc.pick.ammo-weapon_shots>0 then
  36.         hudammobar(cc.pick.ammo-weapon_shots,cc.pick.ammo)
  37.     end
  38.     -- HUD Crosshair
  39.     if cc.pick.ammo-weapon_shots>0 then
  40.         hudcrosshair(7,3)
  41.     end
  42. end
  43.  
  44. function cc.pick.attack(attack)                                        -- Attack
  45.     -- Timer
  46.     if weapon_timer>0 then
  47.         weapon_timer=weapon_timer-1
  48.     end
  49.     if (weapon_shots<cc.pick.ammo) and (weapon_timer<=0) then
  50.         if (attack==1) then
  51.             -- No more weapon switching!
  52.             useweapon(0)
  53.             playsound(cc.pick.sfx_attack)
  54.             weapon_shots=weapon_shots+1
  55.             weapon_timer=22
  56.             -- Collision
  57.             if collision(col20x20,getplayerx(0)+getplayerdirection(0)*21,getplayery(0),1,1)==1 then
  58.                 if playercollision()~=0 and playercollision()~=playercurrent() then
  59.                     playerpush(playercollision(),getplayerdirection(0)*2,-1)
  60.                     playerdamage(playercollision(),10)
  61.                     playsound(sfx_splatter1)
  62.                 end
  63.                 if terraincollision()==1 then
  64.                     playsound(cc.pick.sfx_hitground)
  65.                 end
  66.             end
  67.             -- Free Terrain
  68.             terrainexplosion(getplayerx(0)+getplayerdirection(0)*7+math.sin(math.rad(getplayerrotation(0)))*1,getplayery(0)-1-math.cos(math.rad(getplayerrotation(0)))*3,15,2)
  69.             terrainexplosion(getplayerx(0)+getplayerdirection(0)*7+math.sin(math.rad(getplayerrotation(0)))*10,getplayery(0)-1-math.cos(math.rad(getplayerrotation(0)))*10,15,2)
  70.             -- End Turn
  71.             if weapon_shots>=cc.pick.ammo then
  72.                 endturn()
  73.             end
  74.         end
  75.     end
  76. end
  77.